package general.view 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import morn.core.handlers.Handler;
	import ui.general.GeneralUI;
	import utils.T;
	import vo.GeneralVO;
	
	/**
	 * 武将信息
	 * @author WLDragon 2014-03-13
	 */
	public class General extends GeneralUI 
	{
		
		public function General() 
		{
			super();
			
			head = new Bitmap();
			head.x = 30;
			head.y = 10;
			addChild(head);
			
			config = T.db.getXml(Cnt.XML_EQUIP);
		}
		
		public function update(g:GeneralVO):void
		{
			btName.text = g.name;
			btType.text = Cnt.ARMY_TYPE[g.armyType];
			btWeapon.text = config.equip.(@id == g.weaponID)[0].@name;
			btArmor.text = config.equip.(@id == g.armorID)[0].@name;
			btExp.text = String(g.exp);
			btKnowledge.text = String(g.knowledge);
			btLevel.text = String(g.level);
			btLoyalty.text = String(g.loyalty == 100 ? "--":g.loyalty);
			btMorality.text = String(g.morality);
			btPower.text = String(g.power);
			btSoliders.text = String(g.soliders);
			btStrength.text = String(g.strength);
			
			var bmd:BitmapData = App.asset.getBitmapData("jpg.heads." + g.head);
			if(bmd == null)
				head.bitmapData = App.asset.getBitmapData("jpg.heads.default");
			else
				head.bitmapData = bmd;
		}
		
		private var head:Bitmap;
		private var config:XML;
	}

}